package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldSubject;
import com.cleaningcloud.cld.service.ICldSubjectService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 科目信息Controller
 * 
 * @author cleaningcloud
 * @date 2025-08-12
 */
@RestController
@RequestMapping("/subject")
public class CldSubjectController extends BaseController
{
    @Autowired
    private ICldSubjectService cldSubjectService;

    /**
     * 查询科目信息列表
     */
    @RequiresPermissions("cld:subject:list")
    @GetMapping("/list")
    public AjaxResult list(CldSubject cldSubject)
    {
        List<CldSubject> list = cldSubjectService.selectCldSubjectList(cldSubject);
        return success(list);
    }

    /**
     * 导出科目信息列表
     */
    @RequiresPermissions("cld:subject:export")
    @Log(title = "科目信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldSubject cldSubject)
    {
        List<CldSubject> list = cldSubjectService.selectCldSubjectList(cldSubject);
        ExcelUtil<CldSubject> util = new ExcelUtil<CldSubject>(CldSubject.class);
        util.exportExcel(response, list, "科目信息数据");
    }

    /**
     * 获取科目信息详细信息
     */
    @RequiresPermissions("cld:subject:query")
    @GetMapping(value = "/{subjectId}")
    public AjaxResult getInfo(@PathVariable("subjectId") Long subjectId)
    {
        return success(cldSubjectService.selectCldSubjectBySubjectId(subjectId));
    }

    /**
     * 新增科目信息
     */
    @RequiresPermissions("cld:subject:add")
    @Log(title = "科目信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldSubject cldSubject)
    {
        return toAjax(cldSubjectService.insertCldSubject(cldSubject));
    }

    /**
     * 修改科目信息
     */
    @RequiresPermissions("cld:subject:edit")
    @Log(title = "科目信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldSubject cldSubject)
    {
        return toAjax(cldSubjectService.updateCldSubject(cldSubject));
    }

    /**
     * 删除科目信息
     */
    @RequiresPermissions("cld:subject:remove")
    @Log(title = "科目信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{subjectIds}")
    public AjaxResult remove(@PathVariable Long[] subjectIds)
    {
        return toAjax(cldSubjectService.deleteCldSubjectBySubjectIds(subjectIds));
    }
}
